package demo1;

public class Test3 {
    public static void func(int a) {
        int b = 40 / a;
        System.out.println(b);
        int[] array = null;
        System.out.println(array[1]);
    }
    public static void main(String[] args) {
        int a = 0;
        try {
            func(a);
            System.out.println("try内部的代码被执行了");
        } catch (IndexOutOfBoundsException e) {
            e.printStackTrace();
            System.out.println("捕捉到算数异常");
        } catch (NullPointerException e) {
            e.printStackTrace();
            System.out.println("捕捉到空指针异常");
        }
        System.out.println("try-catch后面的代码被执行了");
    }
}
